package com.xbongbong.pro.enums.permission.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import lombok.Getter;

import java.util.Objects;

/**
 * @author zhouwq
 * @date 2019/5/6 16:22
 */

@Getter
public enum ChartProPermissionAliasEnum {


    /**
     * tb_pro_promission对应图表中心的alias字段
     */
    CHART_VIEW("chartView", "enum.chartProPermissionAlias.memo.chart_view"),

    CHART_ADD("chartAdd", "enum.chartProPermissionAlias.memo.chart_add"),

    CHART_UPDATE("chartUpdate", "enum.chartProPermissionAlias.memo.chart_update"),

    CHART_PUBLISH("chartPublish", "enum.chartProPermissionAlias.memo.chart_publish"),

    /**
     * 自定义图表删除和编辑为同一权限 系统图表没有删除功能
     */
    CHART_DELETE("chartDelete", "enum.chartProPermissionAlias.memo.chart_delete"),

    CHART_EXPORT("chartExport", "enum.chartProPermissionAlias.memo.chart_export"),

    ADD_DASHBOARD("addDashboard","enum.chartProPermissionAlias.memo.add_dashboard")
    ;

    private String alias;

    private String memo;

    ChartProPermissionAliasEnum( String alias, String memo) {
        this.alias = alias;
        this.memo = memo;
    }

    public static ChartProPermissionAliasEnum getByAlias(String alias) {
        for (ChartProPermissionAliasEnum item: values()) {
            if (Objects.equals(item.getAlias(), alias)) {
                return item;
            }
        }
        return null;
    }

    public String getMemo() {
        return I18nMessageUtil.getMessage(memo);
    }
}
